<?php
/*
  功能：用户答题记录表 model
  作者：cxm
  时间：2019-10-23
*/

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class UserQuestionAnswer extends BaseModel {
    use SoftDeletes;
    protected $dates = ['deleted_at']; //开启deleted_at
    protected $table='user_question_answer';  //绑定表

    /**
     * 指定题组的错误数量
     * @param $user_question_id 题组ID
     * @return mixed
     */
    public static function errorNum($user_question_id){
        return self::where('user_question_id',$user_question_id)
                ->whereColumn('answer','!=','right_answer')
                ->pluck('question_id')
                ->toArray();
    }
}